# -*- coding: utf-8 -*-

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os


def generate_launch_description():
    pkg_share = get_package_share_directory('reflector_slam_system')
    params_file = os.path.join(pkg_share, 'config', 'params.yaml')

    use_sim_time = LaunchConfiguration('use_sim_time', default='false')

    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='true',
            description='Use /clock (simulation time)'
        ),
        Node(
            package='reflector_slam_system',
            executable='cloud_stamp_fix_node',
            name='cloud_stamp_fix',
            output='screen',
            parameters=[{'in':'/cx/cloud'}, {'out':'/cx/cloud_now'}],
        ),
        

        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            arguments=['0.3625', '0', '0.45', '0', '0', '3.14159', 'base_link', 'laser_link'],
            parameters=[{'use_sim_time': use_sim_time}],      #  加上这行      上机的时候；别忘了删掉
            output='screen'
        ),

        Node(
            package='reflector_slam_system',
            executable='reflector_detector_node',   # ← 这里改为实际存在的可执行体
            name='reflector_detector_node',
            output='screen',
            parameters=[
                {'use_sim_time': use_sim_time},   #  加上这行！！    上机的时候；别忘了删掉
                params_file,
            ],
            # 如果需要重映射点云话题，可在这里加：
            # remappings=[('/input_cloud', '/cx/cloud')],
        ),
    ])
